{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2950
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	n,ans:int64;
	i:longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
ans:=9*60;
inc(ans,n*45);
for i:=1 to n-1 do 
	if odd(i) then inc(ans,5) else inc(ans,15);
write(ans div 60,' ',ans mod 60);
end.
 